<template>
  <div>
    <h1>信息</h1>
    <br>
    <span>信息</span><br>
    <el-input type="text" v-model="queryInfo" placeholder="" style="width: 10%"></el-input>

    <el-button type="primary" @click="query()">搜索</el-button>
    <br><br>
    <el-row>
      <el-table :data="SQEList" stripe>
        <el-table-column prop="title" label="标题"></el-table-column>
        <el-table-column prop="author" label="作者"></el-table-column>
        <el-table-column prop="createDate" label="时间"></el-table-column>
        <el-table-column label="查看详情">
          <template #default="scope">
            <el-button type="primary" @click="see(scope.row)">查看详情</el-button>
            <el-button type="primary" @click="deleteById(scope.row)">删除</el-button>
          </template>
        </el-table-column>

      </el-table>

    </el-row>
    <br>


    <el-dialog v-model="pick" title="" style="width: 1000px">
      <div v-html="info"></div>
      <el-button type="primary" @click="determine()">确定</el-button>

    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";
import {ElMessage} from "element-plus";

export default {
  name: "Home",
  created() {
    this.query()
  },
  data() {
    return {
      info: "",
      SQEList: [],
      queryInfo: '',
      startTime: '',
      endTime: '',
      pick: false,
      form: {
        purchaseTime: '',
        supplierName: '',
        buyer: ''
      },
      purchaseInfoList: []
    }
  }, methods: {
    public(url) {
      this.pick = true
      axios.post(url, null).then(res => {
        console.log(res.data)
        if (res.data == "ok") {
          ElMessage({
            message: '访问成功',
            type: 'success'
          })
        } else {
          ElMessage({
            message: '你未拥有该权限',
            type: 'success'
          })
        }
      })
    },


    supplier() {
      this.public("/api/user/supplier");

    }, customer() {
      this.public("/api/user/customer");

    }, purchase() {
      this.public("/api/user/purchase");

    }, purchaseInfo() {
      this.public("/api/user/purchaseInfo");

    },


    query() {
      let param = new URLSearchParams
      param.append("queryInfo", this.queryInfo)


      axios.post("/api/news/selectAll", param).then(res => {
        this.SQEList = res.data
      })


    },
    see(scope) {

      this.pick = true
      this.form = scope
      let param = new URLSearchParams()
      param.append('id', scope.newsId)

      axios.post("/api/news/queryEsById", param).then(res => {
        this.info = res.data
      })
    },deleteById(scope){
      let param = new URLSearchParams()
      param.append('id', scope.newsId)
      axios.post("/api/news/deleteById", param).then(res => {
        this.query()
      })
    },
    determine() {
      this.pick = false
    },

  }
}
</script>

<style scoped>

</style>